const loginIdValidatorl = new FieldValidator('txtLoginId', async function(val) {
    if (!val) {
        return '账号不得为空'

    }

})

const loginPwdValidatorl = new FieldValidator('txtLoginPwd', function(val) {
    if (!val) {
        return '请填写密码'
    }
})
const logIDinput = $('#txtLoginId');
const logPWDinput = $('#txtLoginPwd');
console.log(logIDinput, logPWDinput)

const from = $('.user-form');
from.onsubmit = async function(e) {
    e.preventDefault();
    const result = await FieldValidator.validate(
        loginIdValidatorl,
        loginPwdValidatorl
    )
    if (!result) {
        return
    }
    const fromDate = new FormData(from);
    const date = Object.fromEntries(fromDate.entries())
    const resp = await API.login(date)
    if (resp.code === 0) {
        alert('登录成功，点击跳转进入首页')
        location.href = './index.html';
    } else {
        alert('账号或者密码输入有误！请重新输入')
        logIDinputinput.value = '';
        logPWDinput.value = '';

    }
}